//
//  BEScrollViewExtension.swift
//  BasicExtensions
//
//  Created by Fanxx on 2018/3/23.
//  Copyright © 2018年 fanxx. All rights reserved.
//

import UIKit

extension UIScrollView {
    public var currentPage: Int {
        //出现过相差5的情况，暂无找到原因，先加10，若低于10则止方法不适用
        return Int((self.contentOffset.x + 10) / self.bounds.size.width)
    }
    public func scrollToTop(animated: Bool = true) {
        var off = self.contentOffset
        off.y = 0 - self.contentInset.top
        self.setContentOffset(off, animated: animated)
    }
}
